﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;

namespace UniRlv.COL
{
    public class BaseEntity : ICloneable
    {
        public int ID { get; set; }

        public override bool Equals(object obj)
        {
            if (obj != null && this.GetType() == obj.GetType())
            {
                BaseEntity objComp = obj as BaseEntity;

                return objComp.ID == this.ID;
            }

            return false;
        }

        public override string ToString()
        {
            return GetType().Name + "[ID=" + ID + "]";
        }


        public object Clone()
        {
            return this.MemberwiseClone(); //浅复制
        }

        //public object DeepCopy()
        //{
        //    MemoryStream stream = new MemoryStream();
        //    BinaryFormatter formatter = new BinaryFormatter();
        //    formatter.Serialize(stream, this);
        //    stream.Position = 0;
        //    return formatter.Deserialize(stream);
        //}
    }
}
